import {createSlice} from "@reduxjs/toolkit";
import {useSelector} from "react-redux";

const goodsSlice = createSlice({
    name:"goods",
    initialState:{
        goodsList:[]
    },
    reducers:{
        addGoodsList(state,action){
            state.goodsList.push({
                id:state.goodsList.length,
                ...action.payload
            })
        }
    }
});
export const useSelectorGoods = ()=> useSelector(state=>state.goods);
export const {addGoodsList} = goodsSlice.actions;
export default goodsSlice.reducer;